Learning Objectives

After completing this lesson, you’ll be able to:

Instructions

In this lesson, you will:

Resources

Exercise

Jennifer's workspace creates a list of every tree in each park. She's added a TestFilter to filter park polygons that have trees.

She'd like to update the workspace to do the following:

  1. Filter the data to examine parks with trees.
  2. Find the most common genus among all park trees.
  3. Store the name of that genus in a new attribute.

1) Open Starting Workspace and Run It

2) Create a Single List Using a ListBuilder

To get the most common genus, we need to combine the separate lists for each park record into a single list. We can do that using an ListBuilder transformer.

Configuring the ListBuilder

New list attribute

3) Count Genus Names Using a ListHistogrammer

ListHistogrammer parameters

Histogram of genuses

4) Store the Result Using an AttributeCreator

Now we have found the most common genus, we'd like to store its name in an attribute. 

Setting value for TopGenus

Inserting _histogram{}.value

Selecting a list index

Jennifer runs the workspace and inspects the AttributeCreator's Output cache. The new attribute stores the name of the genus:

Results - actual name of genus obscured

Challenges

Challenge #1: Find the most and least common genus for trees within parks.

Challenge #1 Answer: Open after attempting the challenge.

 

Challenge #2: How do you think the process outlined here will handle ties?

Challenge #2 Answer: Open after attempting the challenge.

 

Challenge #3: Don't hard-code the list element in the AttributeCreator. How can you use transformers to extract the index of the most and least common genus instead?

Challenge #3 Answer: Open after attempting the challenge.

@Value(_histogram{@sub(@Value(_element_count),1)}.value)

 

Challenge #4: Is there an easier way to get this answer from the starting data? Do you have to use lists?

Challenge #4 Answer: Open after attempting the challenge.

Yes, in this case, you can actually get the answer without using lists!

Here are the steps for a simple way to do it:

What's the lesson? Lists are powerful, but they are not always necessary! If you can design it, a non-list-based approach is often simpler.

 

Learn More

You can use many other list transformers you could use to continue to process and analyze the tree list. Here are some examples:

Operation Transformer
Count the number of trees in each park ListElementCounter
Find the maximum tree diameter ListSorter & ListIndexer
Find the count of each species ListHistogrammer
Create a list of species ListConcatentaor
Find which parks have an Oak tree ListSearcher
Create a table of park trees with the park name ListExploder
Find the average tree height in a park ListSummer
Find the minimum/maximum of tree diameters ListRangeExtractor

 

Leave Us Feedback on This Lesson